package com.sxkf.template.controller;

import com.sxkf.core.api.vo.R;
import com.sxkf.core.third.os.OsService;
import com.sxkf.core.third.os.vo.response.UploadFileVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.util.PasswordUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;


/**
 * <p>
 * 文件上传 前端控制器
 * </p>
 */
@RestController
@Api(tags = "文件上传模块", value = "文件上传模块相关接口")
@RequestMapping("/upload")
public class UploadFileController {

    @Resource(name = "ossServiceImpl")
    private OsService osService;


    @PostMapping(value = "/uploadFile", produces = "application/json", consumes = "multipart/form-data")
    @ApiOperation(value = "上传文件", produces = "application/json", consumes = "multipart/form-data")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "file", value = "文件", paramType = "query", required = true)
    })
    public R<UploadFileVO> uploadFile(MultipartFile file) throws IOException {
        return R.success(osService.uploadFile(file));
    }



}
